<?php

use think\migration\Migrator;
use think\migration\db\Column;

class Admin extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $this->table('admin',['engine'=>'MyISAM'])
            ->setPrimaryKey('admin_id')
            ->addColumn('admin_name','string',['limit'=>40,'comment'=>'用户名','null'=>false])
            ->addColumn('admin_password','string',['limit'=>100,'comment'=>'登录密码','null'=>false])
            ->addColumn('admin_email','string',['limit'=>100,'comment'=>'邮箱','null'=>true])
            ->addColumn('admin_last_ip','string',['limit'=>200,'comment'=>'上次登录ip','null'=>true])
            ->addColumn('admin_last_time','integer',['comment'=>'上次登录时间','default'=>0])
            ->addColumn('admin_avatar','string',['comment'=>'头像'])
            ->addColumn('admin_register','integer',['comment'=>'注册时间'])
            ->addColumn('admin_status','integer',['comment'=>'用户状态','limit'=>\Phinx\Db\Adapter\PostgresAdapter::INT_SMALL])
            ->create();
    }
}
